package jflowmap.views.heatmap;

import java.awt.Color;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import jflowmap.model.graph.Node;
import jflowmap.util.piccolo.PNodes;
import edu.umd.cs.piccolo.PCamera;
import edu.umd.cs.piccolo.nodes.PPath;

public class Centroid extends PPath {

	private final Node node;
	private final Point2D point;
	private final VisualHeatMap visualHeatMap;
	
	private final double size = 4;
	
	public Centroid (Node node, VisualHeatMap visualHeatMap, Point2D point) {

		this.setPathTo(new Rectangle2D.Double(-size/2, -size/2, size/2, size/2));
		this.point = point;
		this.node = node;
		this.visualHeatMap = visualHeatMap;
		this.setPaint(Color.RED);
	}
	
	public void updatePosition (PCamera camera) {
		Point2D p = getPoint();
		setVisible(camera.getViewBounds().contains(p));
		camera.viewToLocal(p);
		PNodes.setPosition(this, p); 
	}
	
	public Point2D getPoint() {
		return (Point2D) point.clone();
	}
	
	public Node getNode() {
		return node;
	}
}
